import request from '../utils/request';


// 获取文章信息
export function getArticleInfo(id) {
    return request({
        url: `/article/getInfo?id=${id}`,
        method: 'get',
    });
}


// 分页获取文章列表
export function getArticleList(pageSize = 10, currentPage = 1) {
    return request({
        url: `/article/getList?pageSize=${pageSize}&currentPage=${currentPage}`,
        method: 'get',
    });
}


// 添加文章
export function saveArticle(art) {
    return request({
        url: `/article/addart`,
        method: 'post',
        data: art,
        headers: { Authorization: `Bearer ${window.sessionStorage.getItem('token')}` }
    });
}


// 编辑文章
export function editArticle(art) {
    return request({
        url: `/article/updateart`,
        method: 'put',
        data: art,
        headers: { Authorization: `Bearer ${window.sessionStorage.getItem('token')}` }
    });
}


// 删除文章
export function deleteArticle(id) {
    return request({
        url: `/article/delete/${id}`,
        method: 'delete',
        headers: { Authorization: `Bearer ${window.sessionStorage.getItem('token')}` }
    });
}
